#!/usr/bin/env ruby

def cToF(degC)
  return 9.to_f / 5 * (degC + 32)
end

# Method to calculate Tm, melting temperature (short oligos, very rough est. and assumptions)
def meltingTemp(dnaSeq, celcius=true)
  gcCount = dnaSeq.count("gcGC")
  atCount = dnaSeq.count("atAT")
  tm = 4 * gcCount + 2 * atCount
  if(!celcius)
    tm = cToF(tm) # maybe this should be a generic method
  end
  return tm
end


# Example usage:
seq = "aattggcc"
puts "#{seq}: #{meltingTemp(seq)}"

seq = "aattGGcc"
tm2 = meltingTemp(seq, false)
puts "#{seq}: #{tm2} in F"
